//
//  TTBaozhangView.m
//  TaoTuo
//
//  Created by LG on 2020/11/16.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTBaozhangView.h"
#import <UIView+TYAlertView.h>

@interface TTBaozhangView ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *oneBtn;
@property (nonatomic, strong) UILabel *oneLabel;
@property (nonatomic, strong) UIButton *twoBtn;
@property (nonatomic, strong) UILabel *twoLabel;

@property (nonatomic, strong) UIButton *knowBtn;

@end

@implementation TTBaozhangView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        [self setupSubviews];
        
        
    }
    return self;
}

- (void)show
{
    self.transform = CGAffineTransformIdentity;
    [self showInController:[LLRouteTool getRootViewController] preferredStyle:TYAlertControllerStyleActionSheet backgoundTapDismissEnable:YES];
}

- (void)dismiss
{
    [self hideView];
}

- (void)setupSubviews
{
    UIBezierPath *bgPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *bgLayer = [CAShapeLayer layer];
    bgLayer.path = bgPath.CGPath;
    bgLayer.fillColor = UIColor.whiteColor.CGColor;
    [self.layer addSublayer:bgLayer];
    
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(100, 37)];
    [path addLineToPoint:CGPointMake(self.width - 100, 37)];
    CAShapeLayer *layer = [CAShapeLayer layer];
    layer.lineWidth = 2;
    layer.lineDashPattern = @[@2, @3];
    layer.lineCap = kCALineCapRound;
    layer.strokeColor = UIColorHex(#999999).CGColor;
    layer.path= path.CGPath;
    [self.layer addSublayer:layer];
    
    _titleLabel = [UILabel labelWithTitle:@"保障" color:UIColorHex(#333333) font:[UIFont boldSystemFontOfSize:16]];
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    _titleLabel.backgroundColor = UIColor.whiteColor;
    [self addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(26);
        make.width.mas_equalTo(50);
        make.centerX.equalTo(self);
    }];
    
    _oneBtn = [UIButton createButtonWithTitle:@"  七天无理由退货" titleColor:UIColorHex(333333) titleFont:[UIFont boldSystemFontOfSize:15] backgroundColor:nil target:nil action:nil];
    [_oneBtn setImage:[UIImage imageNamed:@"7"] forState:UIControlStateNormal];
    [self addSubview:_oneBtn];
    [_oneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.equalTo(_titleLabel.mas_bottom).offset(30);
    }];
    
    NSString *oneStr = @"请在商品签收之日7天内，符合完好标准的商品，可以申请无理由退货（钻石、定制商品等非现货商品一经购买非质量问题概不退货）。";
    _oneLabel = [UILabel labelWithTitle:oneStr color:UIColorHex(#999999) fontSize:14];
    _oneLabel.numberOfLines = 0;
    [self addSubview:_oneLabel];
    [_oneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.oneBtn.mas_bottom).offset(17.5);
        make.left.mas_equalTo(48);
        make.right.equalTo(self).offset(-33);
    }];
    
    _twoBtn = [UIButton createButtonWithTitle:@"  顺丰物流" titleColor:UIColorHex(333333) titleFont:[UIFont boldSystemFontOfSize:15] backgroundColor:nil target:nil action:nil];
    [_twoBtn setImage:[UIImage imageNamed:@"shunfeng_red"] forState:UIControlStateNormal];
    [self addSubview:_twoBtn];
    [_twoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.oneBtn);
        make.top.equalTo(_oneLabel.mas_bottom).offset(30);
    }];
    
    NSString *twoStr = @"通过邮寄的商品，公司统一采用顺丰快递进行运输。";
    _twoLabel = [UILabel labelWithTitle:twoStr color:UIColorHex(#999999) fontSize:14];
    _twoLabel.numberOfLines = 0;
    [self addSubview:_twoLabel];
    [_twoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.twoBtn.mas_bottom).offset(17.5);
        make.left.right.equalTo(self.oneLabel);
    }];
    
    _knowBtn = [UIButton createButtonWithTitle:@"我知道啦！" titleColor:UIColor.whiteColor titleFont:[UIFont boldSystemFontOfSize:16] backgroundColor:UIColorHex(#8B57E6) cornerRadius:20 target:self action:@selector(dismiss)];
    [self addSubview:_knowBtn];
    [_knowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom).offset(-35);
        make.centerX.equalTo(self);
        make.width.mas_equalTo(161);
        make.height.mas_equalTo(40);
    }];
    
}

@end
